/**
 * Copyright (C) 2010 DustedPixels.com
 */
package com.dustedpixels.cirt.model.machine.spectrum.ula;

import com.dustedpixels.cirt.model.core.Circuit;
import com.dustedpixels.cirt.model.core.Out;
import com.dustedpixels.cirt.model.core.Script;

/**
 * Horizontal / vertical counter.
 * 
 * @author Michal Pociecha-Los (micapolos@gmail.com)
 */
@Circuit
public final class HvCounter {
  // h >= -116, h < 332, h == 0 => beam at first screen column 
  @Out public int h = -116;

  // v >= -56, v < 256, v == 0 => beam at first screen row 
  @Out public int v= -56;
  
  @Script
  public void update() {
    h++;
    if (h == 332) {
      h = -116;
      v++;
      if (v == 192 + 56 + 8) {
        v = -56;
      }
    }
  }
}
